#pragma once

#include<iostream>
#include<vector>
#include<assert.h>

using namespace std;

namespace dsh
{
    template<class T>
    class vector
    {
    public:
        typedef T* iterator;
        vector()
            :_data(nullptr)
             ,_size(0)
             ,_capacity(0)
        {}
        ~vector()
        {
            delete[] _data;
            _data = nullptr;
            _size = _capacity;
        }
        iterator begin()
        {
            return _data;
        }
        iterator end()
        {
            return _data + _size;
        }
        void reserve(size_t n)
        {
            iterator tmp = new T[n];
            if (_data)
            {
                for (size_t i = 0; i < _size; i++)
                {
                    tmp[i] = _data[i];
                }
                delete[] _data;
            }
            _data = tmp;
            _capacity = n;

        }
        void push_back(const T& x)
        {
            if (_size == _capacity)
                reserve(_capacity == 0 ? 4 : _capacity * 2);
            _data[_size] = x;
            _size++;

        }
        void insert(size_t pos, const T& x)
        {
            if (_size == _capacity)
                reserve(_capacity == 0 ? 4 : _capacity * 2);
            size_t end = _size;
            while (end >:)
        }

    private:
        iterator _data;
        size_t _size;
        size_t _capacity;
    };

    void test_vector1()
    {
        vector<int> v;
        v.push_back(1);
        v.push_back(2);
        v.push_back(3);
        v.push_back(4);
        v.push_back(5);
        v.push_back(6);
        for (auto e : v)
        {
            cout << e << " ";
        }
        cout << endl;
    }
}
